package tichu_project252.View;

import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JComponent;

/**
 * This class implements the JComponent ImagePanel.
 *
 * @see <a
 * href="http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JComponent.html">JComponent</a>
 *
 * @author Alexandra Barka, ΑΜ: 2867, login : barka.
 * @version %I%, %G%
 */
public class ImagePanel extends JComponent {

    private Image image;

    /**
     * Sets the image that needs to be "painted".
     *
     * <p><b>Constructor: </b> ImagePanel(Image image) </p>
     *
     * <p><b>Precondition: </b> </p> <p><b>Postcondition: </b> Sets a valid
     * image to the private field image. </p>
     *
     * @param image
     *
     */
    public ImagePanel(Image image) {
        this.image = image;
    }

    /**
     * @see <a
     * href="http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JComponent.html#paintComponent(java.awt.Graphics)">paintComponent</a>
     *
     * @param g
     */
    @Override
    protected void paintComponent(Graphics g) {
        g.drawImage(image, 0, 0, null);

    }
}